#define _CRT_SECURE_NO_WARNINGS  1
#include <algorithm>
#include <vector>
#include<iostream>
#include<string>
using namespace std;


/*
int main()
{
    int n;
    cin >> n;
    vector<int> dp(n + 1);
    if (n == 1 || n == 2)
    {
        cout << 1;
        return 0;
    }
    dp[1] = 1, dp[2] = 1;
    for (int i = 3; i <= n; i++)
    {
        dp[i] = dp[i - 2] + dp[i - 1];
    }

    cout << dp[n];
    return 0;
}

*/

/*
class A {
public:
    ~A() {
        cout << "~A()";
    }
};
class B {
public:
    virtual ~B()
    {
        cout << "~B()";
    }
};
class C : public A, public B 
{
public:
    ~C()
    {
        cout << "~C()";
    }
};
int main() 
{
    C* c = new C;
    B* b1 = dynamic_cast<B*>(c);
    A* a2 = dynamic_cast<A*>(b1);
    delete a2;
}

*/



int main()
{
    string str1, str2;
    while (cin >> str1 >> str2)
    {
        int m = str1.size();
        int n = str2.size();

        vector<vector<bool>> v(m + 1, vector<bool>(n + 1, false));
        v[0][0] = true;
        for (int i = 1; i < m; i++)
        {
            if (str1[i - 1] == '*')
                v[i][0] = v[i - 1][0];
        }
        for (int i = 1; i < m + 1; i++)
        {
            for (int j = 1; j < n + 1; j++)
            {
                if (str1[i - 1] == '*' && isalnum(str2[j - 1]))
                {
                    v[i][j] = v[i - 1][j] || v[i][j - 1];
                }
                else if (toupper(str1[i - 1]) == (toupper(str2[j - 1])))
                {
                    v[i][j] = v[i - 1][j - 1];
                }
                else if (str1[i - 1] == '?' && isalnum(str2[j - 1]))
                {
                    v[i][j] = v[i - 1][j - 1];
                }
                else if (str1[i - 1] == '*')
                {
                    v[i][j] = v[i - 1][j];
                }
            }
        }
        cout << boolalpha << v[m][n] << endl;

    }
}